@extends('admin.layout')
@section('content')
<div class="admin-biaogelist">
	
    <div class="listbiaoti am-cf">
      <ul class="am-icon-flag on">用户管理</ul>
      <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="javascript:void(0);">用户管理</a></dl>
    </div>
	
    <div class="fbneirong">
      <form class="am-form" id="userForm">
        <div class="am-form-group am-cf">
          <div class="zuo">用户名：</div>
          <div class="you">
            <input type="text" class="am-input-sm" name="name" placeholder="请输入用户名" value="{{$user->name}}" readonly>
          </div>
        </div>
          <div class="am-form-group am-cf">
              <div class="zuo">手机号：</div>
              <div class="you">
                  <input type="text" class="am-input-sm" name="phone" placeholder="请输入手机号" value="{{$user->phone}}" readonly>
              </div>
          </div>
          {{--<div class="am-form-group am-cf">
              <div class="zuo">职务：</div>
              <div class="you" style="margin-top: 5px;">
                  <label class="am-radio-inline am-danger">
                      <input type="radio" name="role" value="0" data-am-ucheck {{$user->role == '0' ? 'checked' : 'disabled'}} > 学生
                  </label>
                  <label class="am-radio-inline am-danger">
                      <input type="radio" name="role" value="1" data-am-ucheck {{$user->role == '1' ? 'checked' : ''}}> 教师
                  </label>
                  <label class="am-radio-inline am-danger">
                      <input type="radio" name="role" value="2" data-am-ucheck {{$user->role == '2' ? 'checked' : 'disabled'}}> 其他
                  </label>
              </div>
          </div>--}}
        <div class="am-form-group am-cf">
          <div class="zuo">存储空间(MB)：</div>
          <div class="you">
              <input type="text" class="am-input-sm" name="total_storage" placeholder="请输入用户存储空间" value="{{round($user->total_storage/1024,1)}}">
          </div>
        </div>
          <div class="am-form-group am-cf">
              <div class="zuo">已使用存储空间(MB)：</div>
              <div class="you">
                  <input type="text" class="am-input-sm" name="used_storage" value="{{round($user->used_storage/1024, 2)}}" readonly>
              </div>
          </div>
        
        <div class="am-form-group am-cf">
        <div class="zuo">状态：</div>
        <div class="you" style="margin-top: 5px;">
          <label class="am-radio-inline am-danger">
					    <input type="radio" name="status" value="1" data-am-ucheck {{$user->status == '1' ? 'checked' : ''}}> 开启
					  </label>
					  <label class="am-radio-inline am-danger">
					    <input type="radio" name="status" value="0" data-am-ucheck {{$user->status == '0' ? 'checked' : ''}}> 关闭
					  </label>
            </div>
        </div>
        <div class="am-form-group am-cf">
          <div class="you" style="margin-left: 11%;">
              <input type="button" class="am-btn am-btn-success am-radius" id="submit" value="&nbsp;&nbsp;修改&nbsp;&nbsp;" />
          </div>
        </div>
      </form>
    </div>
</div>
@stop
@section('ownJs')
    <script>
        $(function () {

        });
        $('#submit').click(function(){
            var name = $('input[name="name"]').val();
            var total_storage = $('input[name="total_storage"]').val();
            if(name == ''){
                alert("请填写用户名");
                return false;
            }else if(parseInt(total_storage) == 0){
                alert("请填写存储空间");
                return false;
            }
            var formData = new FormData($( "#userForm" )[0]);
            $.ajax({
                type: 'post',
                url: "/dashboard/modify_user/"+"{{$user->id}}",
                dataType: 'json',
                data: formData,
                async:false,
                cache: false,
                contentType: false,
                processData: false,
                success: function (result) {
                    if (result.code == 0) {
                        alert("操作成功!");
                        self.location=document.referrer;
                    }else if (result.code == 1) {
                        alert("参数错误!");
                    }else if (result.code == 2) {
                        alert("修改失败!");
                    }else if(result.code == -1){
                        location.href = '/dashboard/login';
                    }
                }
            });
        })

    </script>
@stop